#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<stdbool.h>

int CountBit(int n)
{
	int count = 0;
	if (n == 0)
		return 1;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
bool JudeNum(int n)
{
	int square = pow(n, 2);
	int bit = CountBit(n);
	//625
	int mo = pow(10, bit);

	int num = square % mo;
	return n == num;
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	int i = 0;
	int count = 0;
	for (i = 0; i <= n; i++)
	{
		if (JudeNum(i))
			count++;
	}
	printf("%d \n", count);
	return 0;
}